package lainey.ui.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

import lainey.ui.R;

public class IconHintDialog extends Dialog {

    private ImageView mIvIcon;
    private TextView mTvMessage;
    private TextView mTvLeft;
    private TextView mTvRight;

    public IconHintDialog(@NonNull Context context) {
        super(context, R.style.UI_DefaultDialogStyle);
        initDialog(context);
    }

    private void initDialog(Context context) {
        setContentView(R.layout.ui_dialog_icon_hint);
        Window window = getWindow();
        if (window != null) {
            window.getAttributes().gravity = Gravity.CENTER;
        }
        setCancelable(false);
        setCanceledOnTouchOutside(true);
        if (context instanceof Activity) {
            Activity activity = (Activity) context;
            setOwnerActivity(activity);
        }

        mIvIcon = findViewById(R.id.iv_icon);
        mTvMessage = findViewById(R.id.tv_message);
        mTvLeft = findViewById(R.id.tv_left);
        mTvRight = findViewById(R.id.tv_right);
    }

    public void setLeftOnClickListener(View.OnClickListener listener) {
        mTvLeft.setOnClickListener(listener);
    }

    public void setRightOnClickListener(View.OnClickListener listener) {
        mTvRight.setOnClickListener(listener);
    }

    public void setIconResource(int resId) {
        mIvIcon.setImageResource(resId);
    }

    public void setMessage(String text) {
        mTvMessage.setText(text);
    }

    public void setMessage(int resId) {
        mTvMessage.setText(resId);
    }

    public void setLeftText(String text) {
        mTvLeft.setText(text);
    }

    public void setLeftText(int resId) {
        mTvLeft.setText(resId);
    }

    public void setRightText(String text) {
        mTvRight.setText(text);
    }

    public void setRightText(int resId) {
        mTvRight.setText(resId);
    }

    public void setBtnText(int resId, String message, String left, String right) {
        mIvIcon.setImageResource(resId);
        mTvMessage.setText(message);
        mTvLeft.setText(left);
        mTvRight.setText(right);
    }


}
